package com.app.utils;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Toast;

/**
 * 页面工具
 * 
 * @author Administrator
 * 
 */
public class ActivityTools {

	/**
	 * 页面跳转
	 * 
	 * @param act
	 * @param clazz
	 */

	public static void gotoActivity(Activity act, Class clazz) {
		Intent intent = new Intent(act, clazz);
		act.startActivity(intent);
	}

	/**
	 * 触摸时改变按钮背�?
	 * 
	 * @param view
	 * @param imgResId
	 * @param imgResActiveId
	 * @return
	 */
	public static OnTouchListener changeBg(final View view, final int imgResId,
			final int imgResActiveId) {
		return new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					view.setBackgroundResource(imgResActiveId);
				} else if (event.getAction() == MotionEvent.ACTION_UP) {
					view.setBackgroundResource(imgResId);
				}
				return false;
			}
		};
	}

	/**
	 * 带参数的跳转
	 * 
	 * @param act
	 * @param clazz
	 * @param bundle
	 */
	public static void gotoActivity(Activity act, Class clazz, Bundle bundle) {
		Intent intent = new Intent(act, clazz);
		intent.putExtras(bundle);
		act.startActivity(intent);

	}
	
	public static void showTips(Activity act,String text){
		Toast.makeText(act, text, Toast.LENGTH_LONG).show();
	}

}
